subroutine str2id(str,pid)
  use global_param, only: n_point_type
  use global_param, only: pdefect
  implicit none

  character :: str*(*)
  integer,intent(out) :: pid

  integer :: i,j,foo
  integer :: len_str,asci_code

  pid=0

  str=trim(adjustl(str))
  len_str=len_trim(str)
  if (len_str.eq.0) return

  do i=1,n_point_type
     foo=0
     if (len_str.eq.pdefect(i)%len) foo=foo+1
     do j=1,pdefect(i)%len
        asci_code=ichar(str(j:j))
        if (asci_code.eq.pdefect(i)%uppercase(j).or.&
            asci_code.eq.pdefect(i)%lowercase(j)) foo=foo+1
     end do
     if (foo.eq.(pdefect(i)%len+1)) then
        pid=i
        exit
     end if
  end do

  return

end subroutine str2id
